﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Woodlands
{
    class Mail
    {
        public async static Task<long> addMailBox(string email, string password)
        {
            MailBox.MailboxSoapClient mb = new MailBox.MailboxSoapClient("MailboxSoap");
            mb.ClientCredentials.UserName.UserName = "codeninja1";
            mb.ClientCredentials.UserName.Password = "Password12!";
            MailBox.AddMailboxResponse mbr = await mb.AddMailboxAsync("woodlandsuniversity.com", email, 1, 51200, 0, "");
            if (mbr.Body.AddMailboxResult != 1)
            {
                return 0;
            }
            MailLogin.LoginSoapClient ml = new MailLogin.LoginSoapClient("LoginSoap");
            ml.ClientCredentials.UserName.UserName = "codeninja1";
            ml.ClientCredentials.UserName.Password = "Password12!";
            MailLogin.AddLoginResponse mlr = await ml.AddLoginAsync("woodlandsuniversity.com", email, password, "USER", 1, "USER");
            if (mlr.Body.AddLoginResult != 1)
            {
                return 0;
            }
            AddressMap.AddressMapSoapClient ad = new AddressMap.AddressMapSoapClient("AddressMapSoap");
            ad.ClientCredentials.UserName.UserName = "codeninja1";
            ad.ClientCredentials.UserName.Password = "Password12!";
            AddressMap.AddAddressMapResponse add = await ad.AddAddressMapAsync("woodlandsuniversity.com", email, email, 1);

            /*Directory.DirectorySoapClient d = new Directory.DirectorySoapClient("DirectorySoap");
            d.ClientCredentials.UserName.UserName = "codeninja1";
            d.ClientCredentials.UserName.Password = "Password12!";
            Directory.AddDirectoryResponse add = await d.AddDirectoryAsync("woodlandsuniversity.com", email, email);*/
            return add.Body.AddAddressMapResult;
        }
    }
}
